package com.ticket.sass.provider.dto.film;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ticket.sass.provider.model.KeyInfoModel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.LocalDate;
import java.util.List;
import java.util.Objects;

/**
 * @author ywb
 * @date 2024-03-28 16:57
 */
@Data
@ApiModel
public class FilmListOutput {
    private Long id;
    
    @ApiModelProperty(value = "影片名")
    private String name;
    
    @JsonIgnore
    @ApiModelProperty(value = "影片封面")
    private String cover;
    
    @ApiModelProperty(value = "上映时间")
    private LocalDate releaseDate;
    
    @ApiModelProperty(value = "上映地区")
    private String releaseArea;
    
    @ApiModelProperty(value = "导演")
    private String director;
    
    @JsonIgnore
    @ApiModelProperty(value = "主演员")
    private String actor;
    
    @ApiModelProperty(value = "主演员")
    private String[] actors;
    
    @JsonIgnore
    @ApiModelProperty(value = "类型")
    private String type;
    
    @ApiModelProperty(value = "主演员")
    private String[] types;
    
    @ApiModelProperty(value = "片长")
    private Integer duration;
    
    @ApiModelProperty(value = "剧情描述")
    @TableField("\"desc\"")
    private String desc;
    
    @ApiModelProperty("影片评分")
    private Double score;
    
    @ApiModelProperty(value = "影片封面")
    private KeyInfoModel coverModel;
    
    @ApiModelProperty(value = "影片封面")
    private List<FilmVersionOutput> versions;
    
    
    public FilmListOutput() {
    }
    
    public String[] getActors() {
        if (Objects.isNull(actor)){
            return new String[0];
        }
       
        return actor.split(",");
    }
    
    public String[] getTypes() {
        if (Objects.isNull(type)){
            return new String[0];
        }
        
        return type.split(",");
    }
   
    public KeyInfoModel getCoverModel() {
        return new KeyInfoModel(cover);
    }
}
